/*     */ package eos.moe.dragoncore;
/*     */ import blockbuster.BedrockScheme;
/*     */ import blockbuster.emitter.BedrockEmitter;
/*     */ import blockbuster.math.molang.expressions.MolangExpression;
/*     */ import blockbuster.utils.Interpolations;
/*     */ import blockbuster.utils.MatrixUtils;
/*     */ import blockbuster.utils.texture.GifHandler;
/*     */ import blockbuster.utils.texture.GifTexture;
/*     */ import com.google.gson.JsonElement;
/*     */ import com.google.gson.JsonPrimitive;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.UUID;
/*     */ import javax.vecmath.Matrix3f;
/*     */ import net.minecraft.client.Minecraft;
/*     */ import net.minecraft.client.renderer.GlStateManager;
/*     */ import net.minecraft.entity.EntityLivingBase;
/*     */ import net.minecraft.world.World;
/*     */ import net.minecraftforge.client.event.RenderWorldLastEvent;
/*     */ import net.minecraftforge.event.world.WorldEvent;
/*     */ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
/*     */ import net.minecraftforge.fml.common.gameevent.TickEvent;
/*     */ import net.minecraftforge.fml.common.network.FMLNetworkEvent;
/*     */ 
/*     */ @EventBusSubscriber(modid = "dragoncore")
/*     */ public class yx {
/*  29 */   private static final Map<String, BedrockEmitter> w = new HashMap<>();
/*  30 */   private static final Map<String, BedrockEmitter> q = new HashMap<>();
/*     */   
/*     */   private static boolean g;
/*     */   
/*     */   public static void v(String a, String str1, String str2, String str3, String str4, int i) {
/*  35 */     BedrockScheme bedrockScheme = ov.q.v(a);
/*  36 */     BedrockEmitter bedrockEmitter = new BedrockEmitter();
/*  37 */     bedrockEmitter.setScheme(bedrockScheme);
/*  38 */     bedrockEmitter.maxLifeTicks = i;
/*  39 */     bedrockEmitter.setWorld((World)(Minecraft.func_71410_x()).field_71441_e);
/*     */     
/*     */     try {
/*  42 */       String[] arrayOfString = str4.split(",");
/*  43 */       if (arrayOfString.length == 3) {
/*  44 */         bedrockEmitter.extraX = ra.z(arrayOfString[0]);
/*  45 */         bedrockEmitter.extraY = ra.z(arrayOfString[1]);
/*  46 */         bedrockEmitter.extraZ = ra.z(arrayOfString[2]);
/*     */       } 
/*  48 */     } catch (Exception exception) {
/*  49 */       exception.printStackTrace();
/*     */       
/*     */       return;
/*     */     } 
/*     */     try {
/*  54 */       String[] arrayOfString1 = str2.split(",");
/*  55 */       if (arrayOfString1.length == 3) {
/*  56 */         bedrockEmitter.lastGlobal.x = Double.parseDouble(arrayOfString1[0]);
/*  57 */         bedrockEmitter.lastGlobal.y = Double.parseDouble(arrayOfString1[1]);
/*  58 */         bedrockEmitter.lastGlobal.z = Double.parseDouble(arrayOfString1[2]);
/*     */       } else {
/*  60 */         UUID uUID = UUID.fromString(str2);
/*  61 */         EntityLivingBase entityLivingBase = ya.v(uUID);
/*  62 */         bedrockEmitter.setTarget(entityLivingBase);
/*  63 */         bedrockEmitter.targetUUID = uUID;
/*     */         
/*  65 */         bedrockEmitter.lastGlobal.x = Interpolations.lerp(entityLivingBase.field_70169_q, entityLivingBase.field_70165_t, 0.0D);
/*  66 */         bedrockEmitter.lastGlobal.y = Interpolations.lerp(entityLivingBase.field_70167_r, entityLivingBase.field_70163_u, 0.0D);
/*  67 */         bedrockEmitter.lastGlobal.z = Interpolations.lerp(entityLivingBase.field_70166_s, entityLivingBase.field_70161_v, 0.0D);
/*     */       } 
/*     */ 
/*     */       
/*  71 */       str3 = str3.replace("headyaw", "variable.heady").replace("yaw", "variable.bodyyaw").replace("pitch", "variable.headpitch");
/*     */       
/*  73 */       String[] arrayOfString2 = str3.split(",");
/*  74 */       if (arrayOfString2.length == 1 && "look".equalsIgnoreCase(str3)) {
/*  75 */         bedrockEmitter.look = true;
/*  76 */       } else if (arrayOfString2.length == 3) {
/*  77 */         bedrockEmitter
/*     */ 
/*     */           
/*  80 */           .rotationsParser = new MolangExpression[] { bedrockEmitter.scheme.parser.parseJson((JsonElement)new JsonPrimitive(arrayOfString2[0])), bedrockEmitter.scheme.parser.parseJson((JsonElement)new JsonPrimitive(arrayOfString2[1])), bedrockEmitter.scheme.parser.parseJson((JsonElement)new JsonPrimitive(arrayOfString2[2])) };
/*     */       }
/*     */     
/*  83 */     } catch (Exception exception) {
/*  84 */       exception.printStackTrace();
/*     */       
/*     */       return;
/*     */     } 
/*     */     
/*  89 */     if (g) {
/*  90 */       q.put(str1, bedrockEmitter);
/*     */     } else {
/*  92 */       w.put(str1, bedrockEmitter);
/*     */     } 
/*     */     
/*  95 */     bedrockEmitter.added = true;
/*     */   }
/*     */   
/*     */   public static void v(String a) {
/*  99 */     BedrockEmitter bedrockEmitter = w.get(a);
/* 100 */     if (bedrockEmitter != null) {
/* 101 */       bedrockEmitter.maxLifeTicks = 1;
/*     */     }
/*     */   }
/*     */   
/*     */   public static void v(UUID a) {
/* 106 */     g = true;
/* 107 */     for (Map.Entry<String, BedrockEmitter> entry : w.entrySet()) {
/* 108 */       if (a.equals(((BedrockEmitter)entry.getValue()).targetUUID)) {
/* 109 */         ((BedrockEmitter)entry.getValue()).maxLifeTicks = 1;
/*     */         return;
/*     */       } 
/*     */     } 
/* 113 */     g = false;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static void z() {
/* 126 */     List a = new ArrayList();
/* 127 */     g = true;
/* 128 */     for (Map.Entry<String, BedrockEmitter> entry : w.entrySet()) {
/* 129 */       BedrockEmitter bedrockEmitter = (BedrockEmitter)entry.getValue();
/* 130 */       bedrockEmitter.updateTarget();
/* 131 */       bedrockEmitter.update();
/* 132 */       if (bedrockEmitter.isFinished()) {
/* 133 */         a.add(entry.getKey());
/* 134 */         bedrockEmitter.added = false;
/*     */       } 
/*     */     } 
/* 137 */     if (!a.isEmpty()) {
/* 138 */       for (String str : a) {
/* 139 */         w.remove(str);
/*     */       }
/*     */     }
/* 142 */     h();
/* 143 */     g = false;
/*     */   }
/*     */ 
/*     */   
/*     */   public static void v(float a) {
/* 148 */     if (!w.isEmpty()) {
/* 149 */       g = true;
/*     */       
/* 151 */       for (BedrockEmitter bedrockEmitter : w.values()) {
/* 152 */         GlStateManager.func_179094_E();
/*     */         
/* 154 */         if (bedrockEmitter.targetUUID != null) {
/* 155 */           EntityLivingBase entityLivingBase = bedrockEmitter.target;
/* 156 */           if (entityLivingBase == null) {
/*     */             continue;
/*     */           }
/*     */           
/* 160 */           bedrockEmitter.lastGlobal.x = Interpolations.lerp(entityLivingBase.field_70169_q, entityLivingBase.field_70165_t, a);
/* 161 */           bedrockEmitter.lastGlobal.y = Interpolations.lerp(entityLivingBase.field_70167_r, entityLivingBase.field_70163_u, a);
/* 162 */           bedrockEmitter.lastGlobal.z = Interpolations.lerp(entityLivingBase.field_70166_s, entityLivingBase.field_70161_v, a);
/*     */         } 
/* 164 */         bedrockEmitter.prevRotation.set(bedrockEmitter.rotation);
/* 165 */         bedrockEmitter.rotation.setIdentity();
/*     */         
/* 167 */         MolangExpression[] arrayOfMolangExpression = bedrockEmitter.rotationsParser;
/*     */         try {
/* 169 */           if (bedrockEmitter.look) {
/* 170 */             if (bedrockEmitter.target != null) {
/* 171 */               Matrix3f matrix3f = MatrixUtils.getZYXrotationMatrix(0.0F, 
/*     */                   
/* 173 */                   (float)Math.toRadians(-bedrockEmitter.target.field_70759_as), 
/* 174 */                   (float)Math.toRadians(bedrockEmitter.target.field_70125_A));
/*     */               
/* 176 */               bedrockEmitter.rotation.set(matrix3f);
/*     */             } 
/* 178 */           } else if (arrayOfMolangExpression != null && arrayOfMolangExpression.length == 3) {
/* 179 */             if (bedrockEmitter.target != null) {
/* 180 */               float f4 = v(bedrockEmitter.target.field_70758_at, bedrockEmitter.target.field_70759_as, a);
/* 181 */               float f5 = v(bedrockEmitter.target.field_70760_ar, bedrockEmitter.target.field_70761_aq, a);
/* 182 */               float f6 = v(bedrockEmitter.target.field_70127_C, bedrockEmitter.target.field_70125_A, a);
/*     */               
/* 184 */               bedrockEmitter.scheme.parser.setValue("variable.heady", f4);
/* 185 */               bedrockEmitter.scheme.parser.setValue("variable.bodyyaw", f5);
/* 186 */               bedrockEmitter.scheme.parser.setValue("variable.headpitch", f6);
/*     */             } 
/*     */             
/* 189 */             float f1 = (float)arrayOfMolangExpression[0].get();
/* 190 */             float f2 = (float)arrayOfMolangExpression[1].get();
/* 191 */             float f3 = (float)arrayOfMolangExpression[2].get();
/*     */ 
/*     */             
/* 194 */             Matrix3f matrix3f = MatrixUtils.getXYZrotationMatrix(
/* 195 */                 (float)Math.toRadians(f1), 
/* 196 */                 (float)Math.toRadians(f2), 
/* 197 */                 (float)Math.toRadians(f3));
/*     */             
/* 199 */             bedrockEmitter.rotation.set(matrix3f);
/*     */           } 
/* 201 */         } catch (Exception exception) {
/* 202 */           exception.printStackTrace();
/*     */         } 
/*     */         
/* 205 */         bedrockEmitter.render(a);
/*     */         
/* 207 */         bedrockEmitter.running = (bedrockEmitter.maxLifeTicks == 0 || bedrockEmitter.sanityTicks < bedrockEmitter.maxLifeTicks);
/* 208 */         GlStateManager.func_179121_F();
/*     */       } 
/* 210 */       h();
/* 211 */       g = false;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static float v(String a, EntityLivingBase entityLivingBase, float f) {
/* 222 */     if (entityLivingBase != null) {
/* 223 */       if (a.contains("headyaw")) {
/* 224 */         a = a.replace("headyaw", String.valueOf(v(entityLivingBase.field_70758_at, entityLivingBase.field_70759_as, f)));
/*     */       }
/*     */       
/* 227 */       if (a.contains("yaw")) {
/* 228 */         a = a.replace("yaw", String.valueOf(v(entityLivingBase.field_70760_ar, entityLivingBase.field_70761_aq, f)));
/*     */       }
/*     */ 
/*     */ 
/*     */       
/* 233 */       if (a.contains("pitch")) {
/* 234 */         a = a.replace("pitch", String.valueOf(v(entityLivingBase.field_70127_C, entityLivingBase.field_70125_A, f)));
/*     */       }
/*     */     } 
/*     */     
/* 238 */     return (float)ra.z(a);
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public static float v(float a, float f1, float f2) {
/*     */     float f;
/* 245 */     for (f = f1 - a; f < -180.0F; f += 360.0F);
/*     */ 
/*     */ 
/*     */     
/* 249 */     while (f >= 180.0F) {
/* 250 */       f -= 360.0F;
/*     */     }
/*     */     
/* 253 */     return a + f2 * f;
/*     */   }
/*     */   
/*     */   public static void v() {
/* 257 */     w.clear();
/*     */   }
/*     */ 
/*     */   
/*     */   @SubscribeEvent
/*     */   public static void v(WorldEvent.Unload a) {
/* 263 */     v();
/*     */   }
/*     */   
/*     */   @SubscribeEvent
/*     */   public static void v(TickEvent.ClientTickEvent a) {
/* 268 */     if (a.phase == TickEvent.Phase.START) {
/*     */       return;
/*     */     }
/* 271 */     z();
/*     */   }
/*     */   
/*     */   @SubscribeEvent
/*     */   public static void v(FMLNetworkEvent.ClientDisconnectionFromServerEvent a) {
/* 276 */     v();
/*     */   }
/*     */ 
/*     */   
/*     */   @SubscribeEvent
/*     */   public static void v(RenderWorldLastEvent a) {
/* 282 */     for (GifTexture gifTexture : GifHandler.gifs.values())
/* 283 */       gifTexture.func_110550_d(); 
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\yx.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */